<?php

/**
 * 
 * 数据库初始化
 */

include './config.php';

$conn = mysqli_connect(
    $config['mysql']['host'],
    $config['mysql']['username'],
    $config['mysql']['password'],
    $config['mysql']['database']
);


// 空间大小以KB为单位，用户不分等级，容量越买越多
$sql_createDB = "CREATE TABLE IF NOT EXISTS `cloudDisk_user` (" .
    "`id` int(10) NOT NULL AUTO_INCREMENT," .
    "`username` TEXT comment \"用户名\"," .
    "`password` TEXT comment \"密码\"," .
    "`email` TEXT comment \"邮箱\"," .
    "`register_time` CHAR(10) comment \"注册时间\"," .
    "`used_capacity` TEXT comment \"已用空间(KB)\"," .
    "`total_capacity` TEXT comment \"总空间(KB)\"," .
    "PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
mysqli_query($conn, $sql_createDB);

$sql_createDB = "CREATE TABLE IF NOT EXISTS `cloudDisk_file` (" .
    "`id` int(10) NOT NULL AUTO_INCREMENT," .
    "`name` TEXT comment \"文件名称\"," .
    "`upload_time` TEXT comment \"上传时间\"," .
    "`size` TEXT comment \"文件大小(B)\"," .
    "`type` TEXT comment \"文件类型\"," .
    "`objectId` TEXT comment \"文件ID\"," .
    "`creator` TEXT comment \"创建者\"," .
    "PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
mysqli_query($conn, $sql_createDB);



$sql_createDB = "CREATE TABLE IF NOT EXISTS `cloudDisk_verCode` (" .
    "`id` int(10) NOT NULL AUTO_INCREMENT," .
    "`verCode` CHAR(6) comment \"验证码\"," .
    "`email` TEXT comment \"邮箱\"," .
    "`create_time` CHAR(10) comment \"创建时间\"," .
    "PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
mysqli_query($conn, $sql_createDB);
